package servlet;

import bao.CartDao;
import model.Cart;
import service.CartService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class QueryAllCart_Servlrt extends HttpServlet {
    public QueryAllCart_Servlrt() {
        super();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
                super.doPost(req,resp);
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //              设置响应和请求编码字符集
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
//                声明service层对象
        CartDao cartDao = new CartDao();
        List<Cart> carts = cartDao.QueryAllCart();

        req.setAttribute("cart",carts);
        System.out.println(carts);
        req.getRequestDispatcher("main/cart.jsp").forward(req, resp);
    }
}
